<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>04.异步代码执行的顺序</title>
  </head>

  <body>

  </body>
  <script>
    setTimeout(function () {
      console.log(2);
    }, 0)

    setTimeout(() => {
      console.log(4);
    }, 100)

    setTimeout(() => {
      console.log(5);
    }, 100)

    setTimeout(() => {
      console.log(3);
    }, 0)

    console.log(1);

    /* 
    执行顺序为1,2,3,4,5
    先执行同步代码，执行异步代码
    */
  </script>

</html>